package com.desire.test;

import java.util.List;
import java.util.stream.Stream;

public class _04_循环 {
    public static void main(String[] args) {
        //toList  java16 新增技术
        for (int i : Stream.of(1, 2, 3, 4, 56, 8, 43).toList()) {
            System.out.print(i + " ");
        }

        System.out.println("\n<<<<<<<<<<<<*************>>>>>>>>>>>>>");

        //List.of() 接口方法是java9 新增方法
        for (int i : List.of(23, 54, 65)) {
            System.out.print(i + " ");
        }

        System.out.println("\n<<<<<<<<<<<<*************>>>>>>>>>>>>>");

        // for in 循环
        int[] nums = {2, 3, 5, 7, 8, 1};
        for (int num : nums) {
            System.out.print(num + " ");
        }
        System.out.println("\n<<<<<<<<<<<<*************>>>>>>>>>>>>>");

        // 循环遍历 一个 字符串数组
        for (String s : new String[]{"java", "php", "python"}) {
            System.out.print(s + " ");
        }
        System.out.println("\n<<<<<<<<<<<<*************>>>>>>>>>>>>>");

        // 将一个字符串  拆分单个字符  toCharArray
        for (char c : "javascript".toCharArray()) {
            System.out.print(c + " ");
        }

        System.out.println("\n<<<<<<<<<<<<*************>>>>>>>>>>>>>");

        // 获取电脑信息
        /*for (String value : System.getenv().values()) {
            System.out.println(value);
        }
*/

        // split()  以 * 拆分字符串
        String ns = "李四,张三,王五,张三丰,李强";
        for (String s : ns.split(",")) {
            System.out.print(s + " ");
        }
    }
}
